#pragma once

#pragma section("Info$A", read)
#pragma section("Info$M", read)
#pragma section("Info$Z", read)

extern "C" __declspec(selectany) __declspec(allocate("Info$A")) char* first = nullptr;
extern "C" __declspec(selectany) __declspec(allocate("Info$Z")) char* last = nullptr;

#pragma comment(linker,"/merge:Info=.data")

#if defined(_M_IX86)
#define OBJECT_ENTRY_PRAGMA(className) __pragma(comment(linker, "/include:___lpClass_" #className));
#elif defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define OBJECT_ENTRY_PRAGMA(className) __pragma(comment(linker, "/include:__lpClass_" #className));
#else
#error Unknown Platform. define OBJECT_ENTRY_PRAGMA
#endif

#define OBJECT_ENTRY_AUTO(className) \
    extern "C" __declspec(selectany) __declspec(allocate("Info$M")) char* __lpClass_##className=(char*)#className;\
    OBJECT_ENTRY_PRAGMA(className)


class A
{

};

OBJECT_ENTRY_AUTO(A)

class B
{

};

OBJECT_ENTRY_AUTO(B)

class C
{

};

OBJECT_ENTRY_AUTO(C)
